home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / 3d_upd2.cpp next >
C/C++ Source or Header  |  1996-03-07  |  49KB  |  2,301 lines

  1. // 3D pitch test                30/9/94
  2.  
  3. extern "C" int icth,isth;
  4.  
  5. #include <conio.h>
  6. #include <i86.h>
  7. #include <stdlib.h>
  8. #include <bios.h>
  9. #include <stdio.h>
  10. #include <math.h>
  11. #include <string.h>
  12.  
  13. #include "defines.h"
  14. #include "externs.h"
  15. #include "mouse.h"
  16. #include "3deng.h"
  17. #include "data.h"
  18. #include "front.h"
  19. #include "eurofrnt\euro_int.h"
  20. #include "audio.h"
  21.  
  22. int norm_font_col=157;
  23.  
  24. extern team_info game_data[];
  25. extern setup_info setup;
  26.  
  27. extern "C" volatile int ux1,ux2,wptr,rptr;
  28.  
  29. extern int vidi_anim;
  30. extern word scrmode;
  31.  
  32. extern int draw_string(buff_info *buff,int font_no,int x,int y,char *string,unsigned char col,short just);
  33. extern "C" short wConsoleNode;
  34.  
  35. extern float log_factor;
  36.  
  37. int counter=0;
  38.  
  39. struct joy_struct {
  40.     unsigned short x1;
  41.     unsigned short y1;
  42.     unsigned short x2;
  43.     unsigned short y2;
  44.     unsigned short sw;
  45. };
  46.  
  47. extern joy_struct joy_pos;
  48.  
  49. float wayne_cam[2];
  50.  
  51. float set_camera_dist=260;
  52. float set_camera_height=100;
  53. char camera_fixed=0;
  54.  
  55. extern void init_off_int(match_player *player);
  56.  
  57. ////////////////////////////////////////////////////////////
  58.  
  59.  
  60. ////////////////////////////////////////////////////////////
  61.  
  62. extern void get_face_xy(int d,float &x,float &y);
  63.  
  64. ////////////////////////////////////////////////////////////
  65. //// SCREEN PRIMITIVES
  66. //
  67.  
  68. void
  69. grmode(int md)
  70.     {
  71.     union REGS r;
  72.     r.h.al=md;
  73.     r.h.ah=0;
  74.     int386(0x10,&r,&r);
  75.     }
  76. void
  77. vbl()
  78. {
  79.     while(((inp(0x3da))&8)!=0);
  80.     while(((inp(0x3da))&8)==0);
  81. }
  82.  
  83. ////////////////////////////////////////////////////////////
  84. ////////////////////////////////////////////////////////////
  85.  
  86.     extern stad_info stadlist[];
  87.  
  88.     float st_hm=360;
  89.  
  90.     plyrdat *poswr,pos[ncb];
  91.     plyrdat *rep;
  92.  
  93.     filter filters[32];
  94.  
  95.     float spr_coord_tab[MAX_3D_SPRS*3+1];
  96.     short spr_ref_tab[MAX_3D_SPRS];
  97.  
  98.     float null_tab[1]={0};
  99.     short null2[1]={0};
  100.  
  101.     plyrdat coords_tab1[ncb];
  102.     plyrdat coords_tab2[ncb];
  103.  
  104.     plyrdat *replay_tab;
  105.  
  106.     plyrdat *new_coords=coords_tab1;
  107.     plyrdat *old_coords=coords_tab2;
  108.  
  109.     datapt tx,ty,tz,camera_x,camera_y,camera_z;
  110.     int play_cam=1;
  111.  
  112.     datapt old_tx=pitch_len/2;
  113.     datapt old_ty=pitch_wid/2;
  114.     datapt old_tz=0;
  115.     datapt old_camx=0;
  116.     datapt old_camy=0;
  117.     datapt old_camz=0;
  118.     datapt cxs=0;
  119.     datapt cys=0;
  120.     datapt czs=0;
  121.     datapt txs=0;
  122.     datapt tys=0;
  123.     datapt tzs=0;
  124.     datapt prev_camx=0;
  125.     datapt prev_camy=0;
  126.     datapt prev_camz=0;
  127.  
  128.     float old_scale=INIT_SCALE;
  129.     float css=0;
  130.  
  131.     float scale=INIT_SCALE;
  132.  
  133.     char prev_camera;
  134.     short mode_change=0;
  135.  
  136.     const float camera_inertia=0.05;
  137.     const float target_inertia=0.125;
  138.     extern setup_info setup;
  139.     extern match_data match_info;
  140.  
  141.     extern buff_info main_buff;
  142.     extern buff_info vidi_buff;
  143.  
  144.     extern void options(buff_info *buffer,datapt viewx,datapt viewy,datapt viewz,datapt targx,datapt targy,
  145.               datapt targz,datapt vdist,plyrdat *plyrtb,datapt *xyz_ptr,word *ref_ptr,int,int);
  146.  
  147.     extern void substitution(buff_info *buffer,datapt viewx,datapt viewy,datapt viewz,datapt targx,datapt targy,
  148.               datapt targz,datapt vdist,plyrdat *plyrtb,datapt *xyz_ptr,word *ref_ptr,int);
  149.  
  150.     extern void switch_coords();
  151.  
  152. ////////////////////////////////////////////////////////////////
  153. ////////////////////////////////////////////////////////////////
  154.  
  155. int init_3d()
  156. {
  157. //    grmode(19);
  158. //    grmode(0x61);
  159.  
  160.     prev_camera=camera;
  161.     mode_change=0;
  162.     camera_dist=280;
  163.  
  164. // Make sure vectors are corrected...
  165.     new_update_coords();                // Initialize old tab...
  166.     new_update_coords();                // Initialize old tab...
  167.     return(init3d());
  168. }
  169.  
  170. ////////////////////////////////////////////////////////////////
  171. ////////////////////////////////////////////////////////////////
  172.  
  173. ////////////////////////////////////////////
  174. // FUNCTIONS CALLED FROM IN-GAME MENUS... //
  175. ////////////////////////////////////////////
  176.  
  177. /******************************************************************************
  178. *****************************************************************************/
  179.  
  180. void setup_replay()
  181. {
  182.     rep_camera=camera;
  183.     if (camera==15)
  184.         camera=old_cam;
  185. }
  186.  
  187. /******************************************************************************
  188. *****************************************************************************/
  189.  
  190. void reset_replay()
  191. {
  192.     camera=rep_camera;
  193. }
  194.  
  195. /******************************************************************************
  196. *****************************************************************************/
  197.  
  198. void sub_player(short t,short p,short s)
  199. {
  200.     p+=11*(t^(match_half&1));
  201.     player_being_subbed=p+1;
  202.     player_on_off=p+1;
  203.     player_coming_on=s+1;
  204.     init_off_int(&teams[p]);
  205.  
  206.     if (p>10)
  207.         PlaySubstitutionMessage(team_b,p-11,s,FALSE);
  208.     else
  209.         PlaySubstitutionMessage(team_a,p,s,FALSE);
  210. }
  211.  
  212. /******************************************************************************
  213. *****************************************************************************/
  214.  
  215. void do_replay_render3d(float s)
  216. {
  217.     s+=(float)replay_pos/REAL_SPEED;
  218.     if (s>=replay_seconds)
  219.         s-=replay_seconds;
  220.  
  221.     int is1=(int)(s*REAL_SPEED);
  222.     plyrdat *rep1=&replay_tab[is1*ncb];  // Replay Frame...
  223.  
  224.     int is2=(int)(s*REAL_SPEED)+1;
  225.     if (is2>=replay_seconds*REAL_SPEED)
  226.         is2-=replay_seconds*REAL_SPEED;
  227.  
  228.     plyrdat *rep2=&replay_tab[is2*ncb];  // Replay Frame...
  229.  
  230.     memcpy(old_coords,rep1,sizeof(plyrdat)*ncb);
  231.  
  232.     memcpy(new_coords,rep2,sizeof(plyrdat)*ncb);
  233.  
  234.     mf_scale=s*REAL_SPEED-is1;
  235.     realtime_coords();
  236.  
  237.     replay_cnt=TRUE;
  238.     update_3d();
  239.     replay_cnt=FALSE;
  240. }
  241.  
  242. /******************************************************************************
  243. *****************************************************************************/
  244.  
  245. void process_replay()
  246. {
  247.     if (++replay_pos>=replay_seconds*REAL_SPEED)
  248.         replay_pos=0;
  249. }
  250.  
  251. /******************************************************************************
  252. *****************************************************************************/
  253.  
  254. void plr_comments()
  255. {
  256.     plyrdat *ptr=pos;
  257.  
  258.     for (int i=0; i<players; i++)
  259.     {
  260.         if (teams[i].guy_on)
  261.         {
  262.             if (teams[i].tm_comm>0)
  263.             {
  264.                 init_speech(i+1,teams[i].tm_comm,4);
  265.             }
  266.         }
  267.     }
  268. }
  269.  
  270. /******************************************************************************
  271. *****************************************************************************/
  272.  
  273. void process_pitch_sprs()
  274. {
  275.     plr_comments();
  276. }
  277.  
  278. /******************************************************************************
  279. *****************************************************************************/
  280.  
  281. void init_replay()
  282. {
  283. // Fill all replay buffer with current coords etc...
  284.  
  285.     allow_replay=TRUE;
  286.     plyrdat *dest=replay_tab;
  287.     plyrdat *src=pos;
  288.     short reps,n;
  289.  
  290.     for (reps=0; reps<replay_seconds*20; reps++)
  291.     {
  292.         for (short i=0; i<ncb; i++)
  293.         {
  294.             memcpy(dest++,src++,sizeof(plyrdat));
  295.         }
  296.         src-=ncb;
  297.     }
  298. }
  299.  
  300. /******************************************************************************
  301. *****************************************************************************/
  302.  
  303. void draw_string_center(int x,int y,char *st,buff_info *buff)
  304. {
  305.     if (scrmode==0x13)
  306. // Low res...
  307.         draw_string(buff,1,x,y,st,norm_font_col,2);
  308.     else
  309. // Higher res...
  310.         draw_string(buff,2,x,y,st,norm_font_col,2);
  311. }
  312.  
  313. /******************************************************************************
  314. *****************************************************************************/
  315.  
  316. void draw_string_left(int x,int y,char *st,buff_info *buff)
  317. {
  318.     if (scrmode==0x13)
  319. // Low res...
  320.         draw_string(buff,1,x,y,st,norm_font_col,0);
  321.     else
  322. // Higher res...
  323.         draw_string(buff,2,x,y,st,norm_font_col,0);
  324. }
  325.  
  326. /******************************************************************************
  327. *****************************************************************************/
  328.  
  329. void draw_string_right(int x,int y,char *st,buff_info *buff)
  330. {
  331.     if (scrmode==0x13)
  332. // Low res...
  333.         draw_string(buff,1,x,y,st,norm_font_col,1);
  334.     else
  335. // Higher res...
  336.         draw_string(buff,2,x,y,st,norm_font_col,1);
  337. }
  338.  
  339. /******************************************************************************
  340. *****************************************************************************/
  341.  
  342. void set_normal_color(int c)
  343. {
  344.     norm_font_col=c;
  345. }
  346.  
  347. /******************************************************************************
  348. *****************************************************************************/
  349.  
  350. void extra_info()
  351. {
  352.     char info_str_a[16];
  353.     char info_str_b[16];
  354.  
  355.     for (short p=0; p<11; p++)
  356.     {
  357.         switch(xinfo)
  358.         {
  359.             case(1):
  360.                 sprintf(info_str_a,"SPD. %d. %d",(p+1),teams[p].tm_rate);
  361.                 sprintf(info_str_b,"SPD. %d. %d",(p+11),teams[p+11].tm_rate);
  362.                 break;
  363.                 
  364.             case(2):
  365.                 sprintf(info_str_a,"POW. %d. %d",(p+1),teams[p].tm_pow);
  366.                 sprintf(info_str_b,"POW. %d. %d",(p+11),teams[p+11].tm_pow);
  367.                 break;
  368.  
  369.             case(3):
  370.                 sprintf(info_str_a,"CON. %d. %d",(p+1),teams[p].tm_cont);
  371.                 sprintf(info_str_b,"CON. %d. %d",(p+11),teams[p+11].tm_cont);
  372.                 break;
  373.  
  374.             case(4):
  375.                 sprintf(info_str_a,"FLR. %d. %d",(p+1),teams[p].tm_flair);
  376.                 sprintf(info_str_b,"FLR. %d. %d",(p+11),teams[p+11].tm_flair);
  377.                 break;
  378.  
  379.             case(5):
  380.                 sprintf(info_str_a,"VIS. %d. %d",(p+1),teams[p].tm_vis);
  381.                 sprintf(info_str_b,"VIS. %d. %d",(p+11),teams[p+11].tm_vis);
  382.                 break;
  383.  
  384.             case(6):
  385.                 sprintf(info_str_a,"ACC. %d. %d",(p+1),teams[p].tm_ac);
  386.                 sprintf(info_str_b,"ACC. %d. %d",(p+11),teams[p+11].tm_ac);
  387.                 break;
  388.  
  389.             case(7):
  390.                 sprintf(info_str_a,"STM. %d. %d",(p+1),teams[p].tm_stam);
  391.                 sprintf(info_str_b,"STM. %d. %d",(p+11),teams[p+11].tm_stam);
  392.                 break;
  393.  
  394.             case(8):
  395.                 sprintf(info_str_a,"DIS. %d. %d",(p+1),teams[p].tm_disc);
  396.                 sprintf(info_str_b,"DIS. %d. %d",(p+11),teams[p+11].tm_disc);
  397.                 break;
  398.  
  399.             case(9):
  400.                 sprintf(info_str_a,"PER. %d. %d",(p+1),performance[p]);
  401.                 sprintf(info_str_b,"PER. %d. %d",(p+11),performance[p+11]);
  402.                 break;
  403.         }
  404.         draw_string_left(64,32+(p*10),info_str_a,&main_buff);
  405.         draw_string_left(192,32+(p*10),info_str_b,&main_buff);
  406.     }
  407. }
  408.     
  409. /******************************************************************************
  410. *****************************************************************************/
  411.  
  412. extern "C" short state_checksum;
  413. extern int logic_cnt;
  414.  
  415. void info_line()
  416. {
  417.     set_normal_color(WHITE);
  418.  
  419.     char info_str1[14];
  420.     char info_str2[14];
  421.     char info_str3[14];
  422.     char info_str4[10];
  423.     char info_str5[10];
  424.  
  425.     if (setp_taker)
  426.     {
  427.         sprintf(info_str3,"%d    ",teams[setp_taker-1].tm_ac);
  428.         draw_string_center(50,60,info_str3,&main_buff);
  429.         sprintf(info_str3,"%d    ",teams[setp_taker-1].tm_flair);
  430.         draw_string_center(50,80,info_str3,&main_buff);
  431.     }
  432.  
  433.     sprintf(info_str3,"1. %d    ",users[0].plr);
  434.     draw_string_center(150,60,info_str3,&main_buff);
  435.     sprintf(info_str3,"2. %d    ",users[1].plr);
  436.     draw_string_center(150,80,info_str3,&main_buff);
  437.  
  438.     sprintf(info_str3,"3. %d    ",users[2].plr);
  439.     draw_string_center(50,100,info_str3,&main_buff);
  440.     sprintf(info_str3,"4. %d    ",users[3].plr);
  441.     draw_string_center(50,120,info_str3,&main_buff);
  442.  
  443.     sprintf(info_str3,"%d    ",deb_is);
  444.     draw_string_center(150,100,info_str3,&main_buff);
  445. /*
  446.     sprintf(info_str3,"%d    ",users[1].control);
  447.     draw_string_center(150,120,info_str3,&main_buff);
  448.  
  449.     sprintf(info_str3,"%d    ",wConsoleNode);
  450.     draw_string_center(100,140,info_str3,&main_buff);
  451.  
  452.     sprintf(info_str3,"%d    ",deb_a);
  453.     draw_string_center(100,160,info_str3,&main_buff);
  454.  
  455.     sprintf(info_str3,"%1.3f    ",mf_scale);
  456.     draw_string_center(100,180,info_str3,&main_buff);
  457. */
  458.     sprintf(info_str3,"%d    ",good_poss);
  459.  
  460.     sprintf(info_str2,"%d : %d  ",frms_per_sec,game_speed);
  461. //    sprintf(info_str2,"%d : %1.2f  ",frms_per_sec,poss_held);
  462.  
  463. #ifdef CROWD
  464.      switch(crowd_mood_a)
  465.     {
  466.         case(1):
  467.             sprintf(info_str4,"NORMAL   ");
  468.             break;
  469.  
  470.         case(2):
  471.             sprintf(info_str4,"PENSIVE  ");
  472.             break;
  473.  
  474.         case(3):
  475.             sprintf(info_str4,"ENCOURAGE");
  476.             break;
  477.  
  478.         case(4):
  479.             sprintf(info_str4,"EXCITED  ");
  480.             break;
  481.  
  482.         case(5):
  483.             sprintf(info_str4,"CELEBRATE");
  484.             break;
  485.  
  486.         case(6):
  487.             sprintf(info_str4,"BOO...   ");
  488.             break;
  489.  
  490.         case(7):
  491.             sprintf(info_str4,"SAVE     ");
  492.             break;
  493.  
  494.         case(8):
  495.             sprintf(info_str4,"MISS     ");
  496.             break;
  497.  
  498.         case(9):
  499.             sprintf(info_str4,"LAUGH    ");
  500.             break;
  501.     }
  502.  
  503.     switch(crowd_mood_b)
  504.     {
  505.         case(1):
  506.             sprintf(info_str5,"NORMAL   ");
  507.             break;
  508.  
  509.         case(2):
  510.             sprintf(info_str5,"PENSIVE  ");
  511.             break;
  512.  
  513.         case(3):
  514.             sprintf(info_str5,"ENCOURAGE");
  515.             break;
  516.  
  517.         case(4):
  518.             sprintf(info_str5,"EXCITED  ");
  519.             break;
  520.  
  521.         case(5):
  522.             sprintf(info_str5,"CELEBRATE");
  523.             break;
  524.  
  525.         case(6):
  526.             sprintf(info_str5,"BOO...   ");
  527.             break;
  528.  
  529.         case(7):
  530.             sprintf(info_str5,"SAVE     ");
  531.             break;
  532.  
  533.         case(8):
  534.             sprintf(info_str5,"MISS     ");
  535.             break;
  536.  
  537.         case(9):
  538.             sprintf(info_str5,"LAUGH    ");
  539.             break;
  540.     }
  541. #endif
  542.  
  543.     if (replay_cnt)
  544.         sprintf(info_str1,"REPLAY");
  545.     else
  546.     {
  547.         if (match_mode)
  548.         {
  549.             switch(match_mode)
  550.             {
  551.                 case(CORNER_TL):
  552.                 case(CORNER_TR):
  553.                 case(CORNER_BL):
  554.                 case(CORNER_BR):
  555.                     sprintf(info_str1,"CORNER"); 
  556.                     break;
  557.  
  558.                 case(CENTRE_A):
  559.                 case(CENTRE_B):
  560.                     sprintf(info_str1,"CENTRE"); 
  561.                     break;
  562.  
  563.                 case(GOAL_KICK_TL):
  564.                 case(GOAL_KICK_TR):
  565.                 case(GOAL_KICK_BL):
  566.                 case(GOAL_KICK_BR):
  567.                     sprintf(info_str1,"GOAL KICK"); 
  568.                     break;
  569.  
  570.                 case(THROW_IN_A):
  571.                 case(THROW_IN_B):
  572.                     sprintf(info_str1,"THROW IN");
  573.                     break;
  574.  
  575.                 case(IF_KICK_A):
  576.                 case(IF_KICK_B):
  577.                     if (offside_now)
  578.                         sprintf(info_str1,"OFFSIDE FK"); 
  579.                     else
  580.                         sprintf(info_str1,"INDIRECT FK"); 
  581.                     break;
  582.  
  583.                 case(DF_KICK_A):
  584.                 case(DF_KICK_B):
  585.                     sprintf(info_str1,"DIRECT FK"); 
  586.                     break;
  587.  
  588.                 default:
  589.                     sprintf(info_str1,"STOPPED"); 
  590.                     
  591.             };
  592. // Event...
  593.             draw_string_center(50,4,info_str1,&main_buff);
  594.         }
  595.     }
  596.  
  597.     draw_string_center(270,4,info_str3,&main_buff);
  598.     draw_string_center(160,4,":",&main_buff);
  599.     draw_string_center(270,4,info_str3,&main_buff);
  600.  
  601. // Score...
  602.     sprintf(info_str1,"%d - %d",team_a_goals,team_b_goals);
  603.     draw_string_center(160,185,info_str1,&main_buff);
  604.  
  605. // Seconds...
  606.     sprintf(info_str1,"%2.2d",(unsigned short)match_time.sec);
  607.     draw_string_center(164,4,info_str1,&main_buff);
  608.  
  609. // Minutes...
  610.     sprintf(info_str1,"%3d",match_time.min);
  611.     draw_string_center(126,4,info_str1,&main_buff);
  612. }
  613.  
  614. /******************************************************************************
  615. *****************************************************************************/
  616.  
  617. // Switch off camera damping...
  618.  
  619. void damping_off()
  620. {
  621.         old_camx=camera_x;
  622.         old_camy=camera_y;
  623.         old_camz=camera_z;
  624. }
  625.  
  626. /******************************************************************************
  627. *****************************************************************************/
  628.  
  629. void add_message(char *t,short c,char force)
  630. {
  631.     if (force)
  632.     {
  633. // Instant display over-riding current message...
  634.         message_buffer[current_mess].ptr=t;
  635.         message_buffer[current_mess].col=c;
  636.             new_text=MESSAGE_TIME;
  637.         if (!message_cnt)
  638.             message_cnt++;
  639.     }
  640.     else
  641.     {
  642.         if (message_cnt<MAX_MESSAGES)
  643.         {
  644. // Can provide message service...
  645.             short m=message_cnt+current_mess;
  646.             if (m>=MAX_MESSAGES)
  647.                 m-=MAX_MESSAGES;
  648.             short lm=m-1;
  649.             if (lm<0)
  650.                 lm=MAX_MESSAGES-1;
  651.             if (!message_cnt || strcmp(t,message_buffer[lm].ptr))
  652.             {
  653. // New message...
  654.                 message_buffer[m].ptr=t;
  655.                 message_buffer[m].col=c;
  656.                 if (!message_cnt++)
  657.                     new_text=MESSAGE_TIME;
  658.             }
  659.         }
  660.     }
  661. }
  662.  
  663. /******************************************************************************
  664. *****************************************************************************/
  665.  
  666. void display_messages()
  667. {
  668.     if (new_text)
  669.     {
  670.         set_normal_color(message_buffer[current_mess].col);
  671.         draw_string_center(main_buff.clip_wid>>1,main_buff.clip_hgt/16,
  672.                                  message_buffer[current_mess].ptr,&main_buff);
  673.     }
  674. }
  675.  
  676. /******************************************************************************
  677. *****************************************************************************/
  678.  
  679. void change_cam(short c)
  680. {
  681.     set_camera_dist=260;
  682.     set_camera_height=100;
  683.     camera=c;
  684.     char *t;
  685.  
  686.     if (!camera)
  687.         t="FAR";
  688.  
  689.     if (camera==1)
  690.         t="PLAN";
  691.  
  692.     if (camera==2)
  693.         t="G.LINE";
  694.  
  695.     if (camera==3)
  696.         t="MANUAL";
  697.  
  698.     if (camera==4)
  699.         t="PLAYER";
  700.  
  701.     if (camera==5)
  702.         t="USER";
  703.  
  704.     if (camera==6)
  705.         t="FOLLOW";
  706.  
  707.     if (camera==7)
  708.         t="REF.";
  709.  
  710.     if (camera==8)
  711.         t="WIRE";
  712.  
  713.     if (camera==14)
  714.         t="ISO.";
  715.  
  716.     if ((camera<14 && camera>8) || (camera>14))
  717.         t=" ";
  718.  
  719.     add_message(t,YELLOW,TRUE);
  720. }
  721.  
  722. ////////////////////////////////////////////////////////////////
  723. ////////////////////////////////////////////////////////////////
  724.  
  725. void update_3d()
  726. {
  727.     float targ_x,targ_y,targ_z;
  728.     char use_fixed;
  729.     scale=INIT_SCALE;
  730.     char cam_limit=TRUE;
  731.     char cam_buffer=TRUE;
  732.     plyrdat *ptr=pos;            // Tweened object x,y,z and orientations...
  733.  
  734.     float x,y;
  735.  
  736.     if (!line_up)
  737.     {
  738. // Not in pre-match line-up (can use all available camera options)...
  739.         
  740.         if (!replay_cnt)
  741.         {
  742. // No celebration view during replay...
  743.  
  744.             if ((just_scored && just_scored<(SCORE_WAIT-30)) && (camera!=15))
  745.             {
  746. // Camera is forced to follow scorer!
  747.                 old_cam=camera;
  748. #ifdef WAYNE
  749.                 camera=20;
  750.                 if (keys[0x11])    // w
  751.                 {
  752.                     wayne_cam[0]=set_camera_dist;
  753.                     wayne_cam[1]=set_camera_height;
  754.                     FILE *fp1=fopen("wayne","wb");
  755.                     fwrite(wayne_cam,sizeof(float),2,fp1);
  756.                     fclose(fp1);
  757.                     do_penalty_anim(0);
  758.                     do_penalty_menu(0);
  759.                 }
  760.  
  761.                 if (keys[0x2c])    // z
  762.                 {
  763.                     FILE *fp1=fopen("wayne","rb");
  764.                     fread(wayne_cam,sizeof(float),2,fp1);
  765.                     fclose(fp1);
  766.                     set_camera_dist=wayne_cam[0];
  767.                     set_camera_height=wayne_cam[1];
  768.                 }
  769.                     
  770. #else
  771.                 camera=15;            // Follow scorer.
  772. #endif
  773.             }
  774.             else
  775.             {
  776.                 if (!just_scored && camera==15)
  777.                     camera=old_cam;
  778.             }
  779.         }
  780.  
  781.         if (!EUROmatch_info.timeit)
  782.         {
  783.  
  784. #ifdef SUPPORT_LP
  785.             if (users_dir[lp_user-1].f&32 || users_dir[lp_user-1].f&16)
  786.             {
  787.                 if ((keys[0x4b] || (users_dir[lp_user-1].f&4
  788.                       && users_dir[lp_user-1].f&32)) && (set_camera_dist>10))            // keypad 4
  789.                     set_camera_dist-=4;
  790.  
  791.                 if ((keys[0x4d] || (users_dir[lp_user-1].f&8
  792.                       && users_dir[lp_user-1].f&32)) && (set_camera_dist<600))        // keypad 6
  793.                     set_camera_dist+=4;
  794.  
  795.                 if ((keys[0x48] || (users_dir[lp_user-1].f&8
  796.                       && users_dir[lp_user-1].f&16)) && (set_camera_height<600))        // keypad 8
  797.                     set_camera_height+=4;
  798.  
  799.                 if ((keys[0x50] || (users_dir[lp_user-1].f&4
  800.                       && users_dir[lp_user-1].f&16)) && (set_camera_height>10))        // keypad 2
  801.                     set_camera_height-=4;
  802.             }
  803. #endif
  804.  
  805.             if ((keys[0x4b]) && (set_camera_dist>10))            // keypad 4
  806.                 set_camera_dist-=4;
  807.             if ((keys[0x4d]) && (set_camera_dist<600))        // keypad 6
  808.                 set_camera_dist+=4;
  809.  
  810.             if ((keys[0x48]) && (set_camera_height<600))        // keypad 8
  811.                 set_camera_height+=4;
  812.  
  813.             if ((keys[0x50]) && (set_camera_height>10))        // keypad 2
  814.                 set_camera_height-=4;
  815.  
  816.             if (keys[0x4c])                                            // keypad 5
  817.             {
  818.                 set_camera_dist=260;
  819.                 set_camera_height=100;
  820.             }
  821.  
  822.             if (replay_cnt || (!just_scored && match_mode!=SWAP_ENDS))
  823.             {
  824. // Don't allow user to change camera during celebration!
  825.  
  826.                 if (keys[0x02])        // 1            // Autocam
  827.                     change_cam(0);        // camera=0
  828.  
  829.                 if (keys[0x03])        // 2            // Plan
  830.                     change_cam(1);        // camera=1
  831.  
  832.                 if (keys[0x04])        // 3            // 1/2 Plan
  833.                     change_cam(2);        // camera=2
  834.  
  835.                 if (keys[0x05])        // 4
  836.                     change_cam(3);        // camera=3
  837.  
  838.                 if (keys[0x06])        // 5            // Player
  839.                     change_cam(4);        // camera=4
  840.  
  841.                 if (keys[0x07])        // 6            // Wire
  842.                     change_cam(8);        // camera=8
  843.  
  844.                 if (keys[0x08])        // 7            // Referee
  845.                     change_cam(7);        // camera=7
  846.  
  847.                 if (keys[0x09])        // 8            // Isometric
  848.                     change_cam(14);        // camera=14
  849.             }
  850.  
  851.             if (debug)
  852.             {
  853. // don't use these views for normal game.
  854.  
  855.                 if (keys[0x0a])        // 9
  856.                     change_cam(5);        // camera=5
  857.  
  858.                 if (keys[0x0b])        // 0
  859.                     change_cam(6);        // camera=6
  860.             }
  861.  
  862.             if (camera==4)
  863.             {
  864.                 if ((keys[0x48]) && (play_cam<players))    //keypad 8
  865.                     play_cam+=1;
  866.  
  867.                 if ((keys[0x50]) && (play_cam>1))            //keypad 2
  868.                     play_cam-=1;
  869.             }
  870.  
  871. // If in network game and a fixed player has been chosen,
  872. // then all camera views should treat the fixed player (not the ball)
  873. // as the target...
  874.  
  875.             if (network_on && fixed_net_user)
  876.             {
  877. // Fixed player target...
  878.                 targ_x=teams[users[fixed_net_user-1].plr-1].tm_x;
  879.                 targ_y=teams[users[fixed_net_user-1].plr-1].tm_y;
  880.                 targ_z=teams[users[fixed_net_user-1].plr-1].tm_z;
  881.                 use_fixed=TRUE;
  882.             }
  883.             else
  884.             {
  885.                 if (use_ball_limit)
  886.                 {
  887.                     targ_x=ballx_out;
  888.                     targ_y=bally_out;
  889.                     targ_z=ballz_out;
  890.                 }
  891.                 else
  892.                 {
  893.                     targ_x=eff_ballx;
  894.                     targ_y=eff_bally;
  895.                     targ_z=eff_ballz;
  896.                 }
  897.  
  898.                 use_fixed=FALSE;
  899.             }
  900.         }
  901.  
  902. /***************************************/
  903. //  FACE CELEBRATION
  904. /***************************************/
  905.  
  906.         if (camera==15)
  907.         {
  908.             cam_buffer=TRUE;
  909.             tx=teams[goal_scorer-1].tm_x;
  910.             ty=teams[goal_scorer-1].tm_y;
  911.             tz=24;
  912.             camera_x=tx+teams[goal_scorer-1].tm_xdis*set_camera_dist/1.5;
  913.             camera_y=ty+teams[goal_scorer-1].tm_ydis*set_camera_dist/1.5;
  914.             camera_z=set_camera_height/1.5;
  915.         }
  916.  
  917. /***************************************/
  918. //  TUNNEL VEIW
  919. /***************************************/
  920.  
  921.         if (camera==16)
  922.         {
  923.             cam_buffer=TRUE;
  924.             tx=stadlist[setup.stadium].tunlx;
  925.             ty=-stadlist[setup.stadium].tunlz;
  926.             tz=stadlist[setup.stadium].tunly;
  927.  
  928.             camera_x=cntspot_x;
  929.             camera_y=cntspot_y;
  930.             camera_z=40;
  931.         }
  932.  
  933. /***************************************/
  934. // PLAYER ON/OFF VEIW
  935. /***************************************/
  936.  
  937.         if (camera==17)
  938.         {
  939.             short p=player_on_off;
  940.  
  941.             if (player_on_off<0)
  942.                 p=-p;
  943.  
  944.             p-=1;
  945.  
  946.             cam_buffer=TRUE;
  947.             if (-stadlist[setup.stadium].tunlz>cntspot_y)
  948.                 camera_y=teams[p].tm_y-(40+(teams[p].tm_y/2));
  949.             else
  950.                 camera_y=teams[p].tm_y+(40+((pitch_wid-teams[p].tm_y)/2));
  951.  
  952.             camera_x=teams[p].tm_x;
  953.             camera_z=80;
  954.  
  955.             tx=teams[p].tm_x;
  956.             ty=teams[p].tm_y;
  957.             tz=10;
  958.         }
  959.  
  960. /***************************************/
  961. //  MAN OF THE MATCH VEIW
  962. /***************************************/
  963.  
  964.         if (camera==18)
  965.         {
  966.             cam_buffer=TRUE;
  967.             tx=teams[man_of_match-1].tm_x;
  968.             ty=teams[man_of_match-1].tm_y;
  969.             tz=20;
  970.  
  971.             camera_x=tx+(teams[man_of_match-1].tm_xdis*set_camera_dist);
  972.             camera_y=ty+(teams[man_of_match-1].tm_ydis*set_camera_dist);
  973.             camera_z=set_camera_height/2;
  974.         }
  975.  
  976.  
  977. /***************************************/
  978. //  GOAL-SCORER
  979. /***************************************/
  980.  
  981.         if (camera==20)
  982.         {
  983.             cam_buffer=TRUE;
  984.             cam_limit=FALSE;
  985.             float x,y,z,d;
  986.  
  987.             if (last_goal==1)
  988.             {
  989. // B vidi...
  990.                 x=stadlist[setup.stadium].vid2x;
  991.                 y=-stadlist[setup.stadium].vid2z;
  992.                 z=stadlist[setup.stadium].vid2y;
  993.             }
  994.             else
  995.             {
  996. // A vidi...
  997.                 x=stadlist[setup.stadium].vid1x;
  998.                 y=-stadlist[setup.stadium].vid1z;
  999.                 z=stadlist[setup.stadium].vid1y;
  1000.             }
  1001.  
  1002.             tx=x+(teams[goal_scorer-1].tm_x-x)*just_scored/(SCORE_WAIT-30);
  1003.             ty=y+(teams[goal_scorer-1].tm_y-y)*just_scored/(SCORE_WAIT-30);
  1004.             tz=z+(teams[goal_scorer-1].tm_z-z)*just_scored/(SCORE_WAIT-30);
  1005.  
  1006.             x-=teams[goal_scorer-1].tm_x;
  1007.             y-=teams[goal_scorer-1].tm_y;
  1008.             z-=teams[goal_scorer-1].tm_z;
  1009.  
  1010.             d=calc_dist(x,y);
  1011.  
  1012.             x=(x*set_camera_dist*0.5/d);
  1013.             y=(y*set_camera_dist*0.5/d);
  1014.             z=15;
  1015.  
  1016.             camera_x=teams[goal_scorer-1].tm_x-x;
  1017.             camera_y=teams[goal_scorer-1].tm_y-y;
  1018.             camera_z=z;
  1019.         }
  1020.  
  1021. /***************************************/
  1022. //  AUTO-CAMERA
  1023. /***************************************/
  1024.  
  1025.         if (camera==0)
  1026.         {
  1027.             datapt over=((targ_x>cntspot_x) ? (targ_x-cntspot_x)/2:(cntspot_x-targ_x)/2);
  1028.             datapt target_x=(int)(targ_x);
  1029.             datapt target_y=(int)(pitch_wid/2)+((targ_y-cntspot_y)/2)-(targ_z/4)+60;
  1030.             datapt target_z=0; //(int)targ_z;
  1031.     
  1032.             tx=target_x;
  1033.             ty=target_y;
  1034.             tz=target_z;
  1035.     
  1036.             camera_x=(pitch_len/2)+((tx-pitch_len/2)/2);
  1037.             camera_y=(pitch_wid+60)+((targ_y-cntspot_y)/1.5)-(over);
  1038.             camera_z=180-(targ_y/12)+(over/3);
  1039.         }
  1040.  
  1041. /***************************************/
  1042. // PLAN ( Kick-off view )
  1043. /***************************************/
  1044.  
  1045.         if (camera==1)
  1046.         {
  1047.             static float dx=0;
  1048.             static float dy=0;
  1049.             float x,y,dcx,dcy,move_rate;
  1050.     
  1051.             cam_buffer=FALSE;        // Switch camera buffering off!
  1052.             cam_limit=FALSE;        // Switch camera limit off!
  1053.     
  1054.             if (game_speed)
  1055.                 move_rate=(0.2*MF*REAL_SPEED)/game_speed;
  1056.             else
  1057.                 move_rate=0.2;
  1058.             
  1059.             if (ball_still || use_fixed)
  1060.             {
  1061.                 x=targ_x;
  1062.                 y=targ_y;
  1063.             }
  1064.             else
  1065.             {
  1066.                 dx+=((ballxdis*10)-dx)*0.8;
  1067.                 dy+=((ballydis*10)-dy)*0.8;
  1068.     
  1069.                 x=(eff_ballx+dx);
  1070.                 y=(eff_bally+dy);
  1071.             }
  1072.     
  1073.             dcx=x-old_tx;
  1074.             dcy=y-old_ty;
  1075.     
  1076.             cxs+=(dcx*camera_inertia-cxs)*move_rate;
  1077.             cys+=(dcy*camera_inertia-cys)*move_rate;
  1078.     
  1079.             x=old_tx+cxs;
  1080.             y=old_ty+cys;
  1081.     
  1082.             int xhf=(set_camera_height/2.45)-prat*3;
  1083.             int yhf=(set_camera_height/1.6)-prat*2;
  1084.     
  1085.             if (x<xhf)
  1086.                 x=xhf;
  1087.             if (x>pitch_len-xhf)
  1088.                 x=pitch_len-xhf;
  1089.             if (y<yhf)
  1090.                 y=yhf;
  1091.             if (y>pitch_wid-yhf)
  1092.                 y=pitch_wid-yhf;
  1093.     
  1094.             tx=x;
  1095.             ty=y;
  1096.             tz=0;
  1097.     
  1098.             camera_x=x-1;
  1099.             camera_y=y;
  1100.             camera_z=prat*6+set_camera_height;
  1101.         }        
  1102.  
  1103. /***************************************/
  1104. // 1/2 PLAN ( Sensi style view )
  1105. /***************************************/
  1106.  
  1107.         if (camera==2)
  1108.         {
  1109.             static float dx=0;
  1110.             static float dy=0;
  1111.             float x,y,dcx,dcy,move_rate;
  1112.     
  1113.             cam_buffer=FALSE;        // Switch camera buffering off!
  1114.             cam_limit=FALSE;        // Switch camera limit off!
  1115.  
  1116.             if (game_speed)
  1117.                 move_rate=(0.2*MF*REAL_SPEED)/game_speed;
  1118.             else
  1119.                 move_rate=0.2;
  1120.             
  1121.             if (ball_still || use_fixed)
  1122.             {
  1123.                 x=targ_x;
  1124.                 y=targ_y;
  1125.             }
  1126.             else
  1127.             {
  1128.                 dx+=((ballxdis*10)-dx)*0.4;
  1129.                 dy+=((ballydis*10)-dy)*0.4;
  1130.     
  1131.                 x=(eff_ballx+dx);
  1132.                 y=(eff_bally+dy);
  1133.             }
  1134.     
  1135.             dcx=x-old_tx;
  1136.             dcy=y-old_ty;
  1137.     
  1138.             cxs+=(dcx*camera_inertia-cxs)*move_rate;
  1139.             cys+=(dcy*camera_inertia-cys)*move_rate;
  1140.     
  1141.             x=old_tx+cxs;
  1142.             y=old_ty+cys;
  1143.     
  1144.             int xhf=((set_camera_height+8)/2.45)-prat*3;
  1145.             int yhf=(calc_dist(set_camera_dist+(targ_x/6),(set_camera_height+8)/2)/1.6)-prat*3;
  1146.     
  1147.             if (x<xhf)
  1148.                 x=xhf;
  1149.             if (x>pitch_len-xhf)
  1150.                 x=pitch_len-xhf;
  1151.             if (y<yhf)
  1152.                 y=yhf;
  1153.             if (y>pitch_wid-yhf)
  1154.                 y=pitch_wid-yhf;
  1155.     
  1156.             tx=x;
  1157.             ty=y;
  1158.             tz=0;
  1159.     
  1160.             camera_x=x-set_camera_dist-(targ_x/6);
  1161.             camera_y=y;
  1162.             camera_z=(set_camera_height+8);
  1163.         }        
  1164.  
  1165. /***************************************/
  1166. // MANUAL
  1167. /***************************************/
  1168.  
  1169.         if (camera==3)
  1170.         {
  1171.             ReportMouse();
  1172.             camera_x=Mouse.x*2.125-40;
  1173.             camera_y=Mouse.y*4.4-40;
  1174.             camera_z=set_camera_height;
  1175.  
  1176.             tx=targ_x;
  1177.             ty=targ_y;
  1178.             tz=targ_z;
  1179.         }
  1180.  
  1181. /***************************************/
  1182. // PLAYER
  1183. /***************************************/
  1184.  
  1185.         if (camera==4)
  1186.         {
  1187.             cam_buffer=2;
  1188.             camera_x=(ptr+(play_cam-1))->x;
  1189.             camera_z=(ptr+(play_cam-1))->y+PLAYER_HEIGHT-3;
  1190.             camera_y=(ptr+(play_cam-1))->z;
  1191.     
  1192.             x=-(ptr+(play_cam-1))->crot;
  1193.             y=((ptr+(play_cam-1))->srot);
  1194.     
  1195.             tx=camera_x+x*100;
  1196.             ty=camera_y+y*100;
  1197.             tz=PLAYER_HEIGHT-3;
  1198.         }
  1199.  
  1200. /***************************************/
  1201. // USER
  1202. /***************************************/
  1203.  
  1204.         if (camera==5)
  1205.         {
  1206.             camera_x=(ptr+(ball_poss-1))->x;
  1207.             camera_z=(ptr+(ball_poss-1))->y+PLAYER_HEIGHT;
  1208.             camera_y=(ptr+(ball_poss-1))->z+2;
  1209.     
  1210.             x=-(ptr+(ball_poss-1))->crot;
  1211.             y=((ptr+(ball_poss-1))->srot);
  1212.     
  1213.             tx=camera_x+x*100;
  1214.             ty=camera_y+y*100;
  1215.             tz=PLAYER_HEIGHT;
  1216.     
  1217.             damping_off();
  1218.         }
  1219.  
  1220. /***************************************/
  1221. // FOLLOW BALL
  1222. /***************************************/
  1223.  
  1224.         if (camera==6)
  1225.         {
  1226.             float xd,yd;
  1227.     
  1228.             if (ball_poss)
  1229.             {
  1230.                 xd=teams[ball_poss-1].tm_xdis;
  1231.                 yd=teams[ball_poss-1].tm_ydis;
  1232.             }
  1233.             else
  1234.             {
  1235.                 xd=ballxdis;
  1236.                 yd=ballydis;
  1237.             }
  1238.     
  1239.             if ((ABS(xd)<.1) && (ABS(yd)<.1))
  1240.             {
  1241.                 tx=old_tx;
  1242.                 ty=old_ty;
  1243.                 tz=old_tz;
  1244.                 camera_x=old_camx;
  1245.                 camera_y=old_camy;
  1246.                 camera_z=targ_z+40;
  1247.             }
  1248.             else
  1249.             {
  1250.                 float d=calc_dist(xd,yd);
  1251.                 camera_x=targ_x-(120*xd/d);
  1252.                 camera_y=targ_y-(120*yd/d);
  1253.                 camera_z=targ_z+40;
  1254.     
  1255.                 tx=targ_x;
  1256.                 ty=targ_y;
  1257.                 tz=targ_z;
  1258.             }
  1259.         }
  1260.     
  1261.  
  1262. /***************************************/
  1263. // REFEREE
  1264. /***************************************/
  1265.  
  1266.         if (camera==7)
  1267.         {
  1268.             cam_buffer=2;
  1269.             camera_x=(ptr+(players))->x;
  1270.             camera_z=(ptr+(players))->y+PLAYER_HEIGHT-3;
  1271.             camera_y=(ptr+(players))->z;
  1272.     
  1273.             x=-(ptr+(players))->crot;
  1274.             y=(ptr+(players))->srot;
  1275.     
  1276.             tx=camera_x+x*100;
  1277.             ty=camera_y+y*100;
  1278.             tz=PLAYER_HEIGHT-3;
  1279.             damping_off();
  1280.         }
  1281.  
  1282. /***************************************/
  1283. // WIRE
  1284. /***************************************/
  1285.  
  1286.         if (camera==8)
  1287.         {
  1288.  
  1289.             float bxd,byd,d,ox,oy,nx,ny;
  1290.  
  1291.             if ((!match_mode) || (match_mode==CENTRE_A) || (match_mode==CENTRE_B)
  1292.                 || (match_mode>=IF_KICK_A && match_mode<=PEN_KICK_B))
  1293.             {
  1294. // Normal Play...
  1295.                 camera_dist=set_camera_dist;
  1296.     
  1297.                 if (targ_x>cntspot_x)
  1298. // Right goal...
  1299.                 {
  1300.                     bxd=pitch_len-targ_x;
  1301.                     byd=cntspot_y-targ_y;
  1302.                 }
  1303.                 else
  1304.                 {
  1305. // Left goal...
  1306.                     bxd=-targ_x;
  1307.                     byd=cntspot_y-targ_y;
  1308.                 }
  1309.     
  1310.                 d=calc_dist(bxd,byd);
  1311.                 bxd=bxd/d;
  1312.                 byd=byd/d;
  1313.         
  1314.                 ox=0;
  1315.                 oy=-1;
  1316.     
  1317. // get difference (cos a).
  1318.                 float dif=acos((bxd*ox)+(byd*oy));
  1319.                 if (targ_x>cntspot_x)
  1320.                     dif=(((targ_x-cntspot_x)/cntspot_x)*(dif));
  1321.                 else
  1322.                     dif=-(((cntspot_x-targ_x)/cntspot_x)*(dif));
  1323.  
  1324. // The closer to the goal-line, the more in line with ball to goal!
  1325.     
  1326.                 nx=(ox*cos(dif))-(oy*sin(dif));
  1327.                 ny=(oy*cos(dif))+(ox*sin(dif));
  1328.     
  1329.                 tx=targ_x+(nx*(set_camera_dist+20)/3);
  1330.                 ty=targ_y+(ny*(set_camera_dist+20)/3);
  1331.                 tx=targ_x;
  1332.                 ty=targ_y;
  1333.                 tz=targ_z/2;
  1334.     
  1335.                 camera_x=targ_x-(nx*(set_camera_dist+20));
  1336.                 camera_y=targ_y-(ny*((set_camera_dist+20)
  1337.                             -((set_camera_dist+20)*(targ_y/(pitch_wid*2)))));
  1338.                 camera_z=(set_camera_height+20)-(((set_camera_height+20)*.8)*(ABS((targ_y-cntspot_y)/cntspot_y)));
  1339.     
  1340.                 if (targ_y<cntspot_y)
  1341.                     camera_y=camera_y+((cntspot_y-targ_y)/20);
  1342.     
  1343. // Now bring target in according to height...
  1344.  
  1345.                 bxd=camera_x-tx;
  1346.                 byd=camera_y-ty;
  1347.                 d=calc_dist(bxd,byd);
  1348.                 bxd=tx+(bxd*camera_z/(d*5));
  1349.                 byd=ty+(byd*camera_z/(d*5));
  1350.     
  1351.                 tx=bxd;
  1352.                 ty=byd;
  1353.             }
  1354.             else
  1355.             {
  1356.                 switch(match_mode)
  1357.                 {
  1358.     
  1359.                     case(GOAL_KICK_TL):
  1360.                     case(GOAL_KICK_BL):
  1361.                         camera=9;
  1362.                         break;
  1363.     
  1364.                     case(GOAL_KICK_TR):
  1365.                     case(GOAL_KICK_BR):
  1366.                         camera=10;
  1367.                         break;
  1368.     
  1369.                     case(CORNER_TL):
  1370.                     case(CORNER_BL):
  1371.                         camera=11;
  1372.                         break;
  1373.     
  1374.                     case(CORNER_TR):
  1375.                     case(CORNER_BR):
  1376.                         camera=12;
  1377.                         break;
  1378.     
  1379.                     case(THROW_IN_A):
  1380.                     case(THROW_IN_B):
  1381.                         camera=13;
  1382.                         break;
  1383.  
  1384.                 }
  1385.             }
  1386.         }
  1387.  
  1388. /***************************************/
  1389. /***************************************/
  1390.  
  1391.         if (camera==9)
  1392. // Goal kick from left...
  1393.         {
  1394.             camera_y=cntspot_y;
  1395.             camera_x=eff_ballx-set_camera_dist;
  1396.             camera_z=eff_ballz/2+set_camera_height;
  1397.             tx=eff_ballx+((cntspot_x-eff_ballx)/10);
  1398.             ty=eff_bally;
  1399.             tz=eff_ballz;
  1400.             if (match_mode!=GOAL_KICK_TL && match_mode!=GOAL_KICK_BL)
  1401.                 camera=8;
  1402.         }
  1403.  
  1404. /***************************************/
  1405. /***************************************/
  1406.  
  1407.         if (camera==10)
  1408. // Goal kick from right...
  1409.         {
  1410.             camera_y=cntspot_y;
  1411.             camera_x=eff_ballx+set_camera_dist;
  1412.             camera_z=eff_ballz/2+set_camera_height;
  1413.             tx=eff_ballx-((eff_ballx-cntspot_x)/10);
  1414.             ty=eff_bally;
  1415.             tz=eff_ballz;
  1416.             if (match_mode!=GOAL_KICK_TR && match_mode!=GOAL_KICK_BR)
  1417.                 camera=8;
  1418.         }
  1419.  
  1420. /***************************************/
  1421. /***************************************/
  1422.  
  1423.         if (camera==11)
  1424. // Corner kick at left goal...
  1425.          {
  1426.             float bxd,byd,d;
  1427.             tx=prat*12;
  1428.             ty=cntspot_y;
  1429.             tz=0;
  1430.             bxd=eff_ballx-tx;
  1431.             byd=eff_bally-ty;
  1432.             d=calc_dist(bxd,byd);
  1433.             camera_x=eff_ballx+(bxd*set_camera_dist/d);
  1434.             camera_y=eff_bally+(byd*set_camera_dist/d);
  1435.             camera_z=set_camera_height/4;
  1436.             if ((!match_mode) && (last_touch!=corner_taker))
  1437.                 camera=8;
  1438.         }
  1439.  
  1440. /***************************************/
  1441. /***************************************/
  1442.  
  1443.         if (camera==12)
  1444. // Corner kick at right goal...
  1445.         {
  1446.             float bxd,byd,d;
  1447.             tx=pitch_len-(prat*12);
  1448.             ty=cntspot_y;
  1449.             tz=0;
  1450.             bxd=eff_ballx-tx;
  1451.             byd=eff_bally-ty;
  1452.             d=calc_dist(bxd,byd);
  1453.             camera_x=eff_ballx+(bxd*set_camera_dist/d)/2;
  1454.             camera_y=eff_bally+(byd*set_camera_dist/d)/2;
  1455.             camera_z=set_camera_height/4;
  1456.             if ((!match_mode) && (last_touch!=corner_taker))
  1457.                 camera=8;
  1458.         }
  1459.  
  1460. /***************************************/
  1461. /***************************************/
  1462.  
  1463.         if (camera==13)
  1464. // Throw in...
  1465.         {
  1466.             tx=eff_ballx;
  1467.             ty=eff_bally;
  1468.             tz=eff_ballz;
  1469.             camera_x=eff_ballx;
  1470.             camera_y=eff_bally;
  1471.     
  1472.             if (bally>cntspot_y)
  1473.                 camera_y+=set_camera_dist/2;
  1474.             else
  1475.                 camera_y-=set_camera_dist/2;
  1476.     
  1477.             camera_z=eff_ballz+set_camera_height/4;
  1478.     
  1479.             if ((!match_mode) && (last_touch!=throw_in_taker))
  1480.                 camera=8;
  1481.         }
  1482.  
  1483. /***************************************/
  1484. // ISOMETRIC
  1485. /***************************************/
  1486.  
  1487.         if (camera==14)
  1488.         {
  1489.             tx=targ_x;
  1490.             ty=targ_y+((cntspot_y-targ_y)/4);
  1491.             tz=targ_z;
  1492.             
  1493.             camera_x=tx-20-set_camera_dist*1.4;
  1494.             camera_y=ty+20+set_camera_dist*1.4;
  1495.             camera_z=targ_z/3+(set_camera_height*2);
  1496.     
  1497.             scale=512*2;
  1498.             cam_limit=TRUE;
  1499.         }
  1500.     }
  1501.  
  1502.     else
  1503.  
  1504.     {
  1505. // Pre-match Line-up!!!
  1506.  
  1507.         if (first_update)
  1508.         {
  1509.             cam_buffer=FALSE;
  1510.             first_update=FALSE;
  1511.         }
  1512.         else
  1513.             cam_buffer=TRUE;
  1514.  
  1515.         if (line_up>=40)
  1516.         {
  1517. // Move camera...
  1518.             cam_limit=FALSE;
  1519.  
  1520.             float rad=((LINE_UP_DELAY+40-line_up)*(LINE_UP_DELAY+40-line_up))/90;
  1521.             float ang=(float)(line_up-40)/LINE_UP_DELAY*PI;
  1522.             tx=ballx;
  1523.             ty=bally;
  1524.             tz=ball_diam/2;
  1525.             camera_x=tx-(3*rad*sin(ang));
  1526.             camera_y=ty+(3*rad*cos(ang))-30;
  1527.             camera_z=20+rad;
  1528. /*
  1529.             y=(float)(line_up-40)/LINE_UP_DELAY;
  1530.             camera_z=prat*2+(y*y*y*y*(prat*60));
  1531.             camera_x=cntspot_x;
  1532.             camera_y=cntspot_y+80+(y*y*(prat*80));
  1533.             tx=cntspot_x;
  1534.             ty=cntspot_y+(y*y*(prat*30));
  1535.             tz=0;
  1536. */
  1537.         }
  1538.     }        
  1539.  
  1540. /***************************************/
  1541. /***************************************/
  1542.  
  1543. #define PULL_BACK_FACTOR 1.
  1544.  
  1545.     if (prev_camera!=camera)
  1546.         mode_change=CAM_MODE_BUFFER;
  1547.  
  1548.     prev_camera=camera;
  1549.  
  1550.     float cur_camx,cur_camy,cur_camz,cur_tx,cur_ty,cur_tz;
  1551.     float dif_camx,dif_camy,dif_camz,dif_tx,dif_ty,dif_tz,dif_scale;
  1552.     static float move_rate=0.4;
  1553.  
  1554.     if (!line_up && camera==8 && camera==6)
  1555.     {
  1556.         float d=calc_dist(tx-camera_x,ty-camera_y);
  1557.         d=calc_dist(tz-camera_z,d);
  1558.         x=(camera_x-tx)/d;
  1559.         y=(camera_y-ty)/d;
  1560.         float z=(camera_z-tz)/d;
  1561.         float cam_dist=calc_dist(set_camera_dist,set_camera_height);
  1562.  
  1563.         float r=(d/cam_dist)*PULL_BACK_FACTOR;
  1564.         camera_x=tx+(r*d*x);
  1565.         camera_y=ty+(r*d*y);
  1566.         camera_z=tz+(r*d*z);
  1567.     }
  1568.  
  1569. // Stadium Perimeter as defined by 3d engine...
  1570.     int st_l=stadlist[setup.stadium].st_l;
  1571.     int st_w=stadlist[setup.stadium].st_w;
  1572.     int st_h=stadlist[setup.stadium].st_h;
  1573.  
  1574.     if (cam_limit)
  1575.     {
  1576. // Camera cannot go far off pitch...
  1577.         if (camera_x<-st_l/2)
  1578.             camera_x=-st_l/2;
  1579.         if (camera_x>pitch_len+(st_l/2))
  1580.             camera_x=pitch_len+(st_l/2);
  1581.         if (camera_y<-st_w/2)
  1582.             camera_y=-st_w/2;
  1583.         if (camera_y>pitch_wid+(st_w/2))
  1584.             camera_y=pitch_wid+(st_w/2);
  1585.         if (camera_z>st_hm)
  1586.             camera_z=st_hm;
  1587.     }
  1588.  
  1589.     if (cam_buffer)
  1590.     {
  1591. // Tween scale...
  1592.         dif_scale=scale-old_scale;
  1593.  
  1594. // Camera buffering...
  1595.         dif_camx=camera_x-old_camx;
  1596.         dif_camy=camera_y-old_camy;
  1597.         dif_camz=camera_z-old_camz;
  1598.  
  1599.         dif_tx=tx-old_tx;
  1600.         dif_ty=ty-old_ty;
  1601.         dif_tz=tz-old_tz;
  1602.  
  1603.         if (!replay_cnt)
  1604.         {
  1605. // Time Camera movement...
  1606.             if (count>old_count+(TIMER_SPEED/2))
  1607. // Half a second interval...
  1608.             {
  1609.                 old_count+=(TIMER_SPEED/2);
  1610.                 if (!updates)
  1611.                     updates=1;
  1612.  
  1613.                 if (camera==3)
  1614.                     move_rate=1./updates;        // Mouse control disregards game speed!
  1615.                 else
  1616.                     move_rate=1./updates*game_speed/REAL_SPEED;
  1617.  
  1618.                 updates=0;
  1619.             }
  1620.         }
  1621.         else
  1622.         {
  1623. // No need to time...
  1624.             move_rate=0.2;
  1625.         }
  1626.  
  1627.         if (dif_camx>MAX_CAM_DIF)
  1628.             dif_camx=MAX_CAM_DIF;
  1629.  
  1630.         if (dif_camy>MAX_CAM_DIF)
  1631.             dif_camy=MAX_CAM_DIF;
  1632.  
  1633.         if (dif_camz>MAX_CAM_DIF)
  1634.             dif_camz=MAX_CAM_DIF;
  1635.  
  1636.         if (dif_camx<-MAX_CAM_DIF)
  1637.             dif_camx=-MAX_CAM_DIF;
  1638.  
  1639.         if (dif_camy<-MAX_CAM_DIF)
  1640.             dif_camy=-MAX_CAM_DIF;
  1641.  
  1642.         if (dif_camz<-MAX_CAM_DIF)
  1643.             dif_camz=-MAX_CAM_DIF;
  1644.  
  1645.         if (dif_tx>MAX_CAM_DIF)
  1646.             dif_tx=MAX_CAM_DIF;
  1647.  
  1648.         if (dif_ty>MAX_CAM_DIF)
  1649.             dif_ty=MAX_CAM_DIF;
  1650.  
  1651.         if (dif_tz>MAX_CAM_DIF)
  1652.             dif_tz=MAX_CAM_DIF;
  1653.  
  1654.         if (dif_tx<-MAX_CAM_DIF)
  1655.             dif_tx=-MAX_CAM_DIF;
  1656.  
  1657.         if (dif_ty<-MAX_CAM_DIF)
  1658.             dif_ty=-MAX_CAM_DIF;
  1659.  
  1660.         if (dif_tz<-MAX_CAM_DIF)
  1661.             dif_tz=-MAX_CAM_DIF;
  1662.  
  1663.         cur_camx=old_camx+(dif_camx*move_rate);
  1664.         cur_camy=old_camy+(dif_camy*move_rate);
  1665.         cur_camz=old_camz+(dif_camz*move_rate);
  1666.  
  1667.         cur_tx=old_tx+(dif_tx*move_rate*1.5);
  1668.         cur_ty=old_ty+(dif_ty*move_rate*1.5);
  1669.         cur_tz=old_tz+(dif_tz*move_rate*1.5);
  1670.     }
  1671.     else
  1672.     {
  1673.         cur_camx=camera_x;
  1674.         cur_camy=camera_y;
  1675.         cur_camz=camera_z;
  1676.         cur_tx=tx;
  1677.         cur_ty=ty;
  1678.         cur_tz=tz;
  1679.     }
  1680.  
  1681. #ifndef DEMO
  1682.     if (opt_user && !replay_cnt)
  1683.     {
  1684.         plyrdat *buff=new_coords;
  1685.  
  1686. // In Game options menu(Formation,Subs,Replay)
  1687.         old_rep_pos=replay_pos;
  1688.         replay_pos++;    // In case of replay point to first frame...
  1689.  
  1690.         if (opt_user==100)
  1691.         {
  1692. // Substitution Menu...
  1693.             sub_camera=camera;
  1694.             camera=17;
  1695.             subbing_now=SUB_DELAY;
  1696.             substitution(&main_buff,cur_camx,cur_camz,cur_camy,
  1697.                             cur_tx,cur_tz,cur_ty,
  1698.                             scale,pos,&spr_coord_tab[0],&spr_ref_tab[0],opt_team);
  1699.             if (!player_being_subbed)
  1700.                 camera=sub_camera;
  1701.             opt_user=FALSE;
  1702.         }
  1703.         else
  1704.         {
  1705.             options(&main_buff,cur_camx,cur_camz,cur_camy,
  1706.                         cur_tx,cur_tz,cur_ty,
  1707.                         scale,pos,&spr_coord_tab[0],&spr_ref_tab[0],--opt_user,opt_team);
  1708.         }
  1709.  
  1710. //        if (buff!=new_coords)
  1711. //            switch_coords();
  1712.         replay_pos=old_rep_pos;
  1713.         old_count=count;
  1714.         opt_user=0;
  1715.         stop_mf_time();
  1716.     }
  1717.     else
  1718. #endif
  1719.     {
  1720.         if (key_togs[0x0a] && !vidi_anim)                // 9
  1721. // Vidi screen on...
  1722.         {
  1723.             render3d(&vidi_buff,cntspot_x,cur_camz,pitch_wid+80,
  1724.                     eff_ballx,eff_ballz,eff_bally,
  1725.                     scale,pos,&spr_coord_tab[0],&spr_ref_tab[0]);
  1726.             vidi_buff.dump(0,0);
  1727.         }
  1728.  
  1729. // Straight to Vram...
  1730. //        main_buff.buff_start=(unsigned char *)0xa0000;
  1731.  
  1732. // Update display buffer...
  1733.           render3d(&main_buff,cur_camx,cur_camz,cur_camy,
  1734.                       cur_tx,cur_tz,cur_ty,
  1735.                       scale,pos,&spr_coord_tab[0],&spr_ref_tab[0]);
  1736.       }
  1737.  
  1738. // Overlaid sprites...
  1739.         if (debug)
  1740.         {
  1741.             info_line();
  1742.             if (xinfo)
  1743.                 extra_info();
  1744.         }
  1745.  
  1746. // New Message...
  1747.     display_messages();
  1748.  
  1749. #ifdef EURO96
  1750. // Name of player in possession...
  1751.     if (last_touch && match_mode!=THROW_IN_A && match_mode!=THROW_IN_B)
  1752.     {
  1753.         short c;
  1754.         short p=last_touch;
  1755.         char name[20];
  1756.  
  1757.         if (p<12)
  1758.             c=(match_half&1 ? 1:0);
  1759.         else
  1760.             c=(match_half&1 ? 0:1);
  1761.  
  1762.         p=standard_player(p);
  1763.         itoa(teams[last_touch-1].shirt,name,10);
  1764.  
  1765.         char *n=&game_data[country(c)].players[p-1].name[game_data[country(c)].players[p-1].goal_index];
  1766.         strcat(name,". ");
  1767.         strcat(name,n);
  1768.  
  1769.         if (!c)
  1770.         {
  1771.             set_normal_color(TEAM1COL);
  1772.             draw_string_left(8,1,name,&main_buff);
  1773.         }
  1774.         else
  1775.         {
  1776.             set_normal_color(TEAM2COL);
  1777.             draw_string_right(main_buff.clip_wid-8,1,name,&main_buff);
  1778.         }
  1779.     }
  1780. #endif
  1781.  
  1782. /* Goal Sprite Out...
  1783.         if (just_scored>0 && !replay_cnt)
  1784.         {
  1785. // OUT
  1786.             shadow_sprite(160*2+6,100*2+8,0,&main_buff);
  1787.             overlay_sprite(160*2,100*2,0,&main_buff);
  1788.         }
  1789. */
  1790.  
  1791.     main_buff.dump(0,0);
  1792.  
  1793.     old_tx=cur_tx;
  1794.     old_ty=cur_ty;
  1795.     old_tz=cur_tz;
  1796.     old_camx=cur_camx;
  1797.     old_camy=cur_camy;
  1798.     old_camz=cur_camz;
  1799.     old_scale=scale;
  1800. }
  1801.  
  1802. /******************************************************************************
  1803. *****************************************************************************/
  1804.  
  1805. void pass_coords(plyrdat *ptr)
  1806. {
  1807.     float x,y;
  1808.     plyrdat *rep=&replay_tab[replay_pos*ncb];  // Replay Frame...
  1809.  
  1810.     int col;
  1811.     if (replay_cnt && replay_seconds)
  1812.     {
  1813. // Replay On....
  1814. // Use Replay Table only...
  1815.  
  1816.         memcpy(ptr,rep,sizeof(plyrdat)*ncb);
  1817.  
  1818.     }
  1819.     else
  1820.     {
  1821. // Normal Game mode....
  1822. // Update Replay table also...
  1823.  
  1824.         for (int i=0; i<players+3; i++)
  1825.         {
  1826.             if (i>=players)
  1827.             {
  1828. // Officials
  1829.  
  1830.                 ptr->x=(datapt)(refs[i-(players)].x); //x
  1831.  
  1832.                 ptr->y=(datapt)(refs[i-(players)].z); //y
  1833.  
  1834.                 ptr->z=(datapt)(refs[i-(players)].y); //z
  1835.  
  1836.                 if (i==players)
  1837.                     ptr->type=3; //referee colour
  1838.                 else
  1839.                     ptr->type=4; //linesman colour
  1840.  
  1841.                 ptr->crot=refs[i-(players)].dir_x;
  1842.  
  1843.                 ptr->srot=refs[i-(players)].dir_y;
  1844.  
  1845.                 ptr->anim=refs[i-(players)].anim;            //anim seq.
  1846.  
  1847.                 ptr->frame=refs[i-(players)].frm;            //anim frm.
  1848.  
  1849.                 ptr->fstep=refs[i-(players)].fstep;            //anim fstep.
  1850.  
  1851.                 ptr->htype=0;        // htype
  1852.                 ptr->hcol=0;        // hcol
  1853.  
  1854.                 if (speech_tab[i].cnt)
  1855.                     ptr->sprite=speech_tab[i].say;
  1856.                 else
  1857.                     ptr->sprite=-1;
  1858.  
  1859.                 ptr++;
  1860.             }
  1861.             else
  1862.             {
  1863.                 ptr->x=(datapt)(teams[i].tm_x); //x
  1864.  
  1865.                 ptr->y=(datapt)(teams[i].tm_z); //y
  1866.  
  1867.                 ptr->z=(datapt)(teams[i].tm_y); //z
  1868.  
  1869.                 if (!teams[i].guy_on)
  1870. // Not on field...
  1871.                     ptr->type=FALSE;
  1872.                 else
  1873.                 {
  1874.                     if (teams[i].draw_me)
  1875.                     {
  1876.                         if (match_half&1)
  1877.                         {
  1878.                             if (i>=players/2)
  1879.                                 col=1;
  1880.                             else
  1881.                                 col=2;
  1882.                             
  1883.                         }
  1884.                         else
  1885.                         {
  1886.                             if (i>=players/2)
  1887.                                 col=2;
  1888.                             else
  1889.                                 col=1;
  1890.                         }
  1891.                     }
  1892.                     else
  1893.                         col=FALSE;        // Don't draw him!
  1894.  
  1895.                     ptr->type=col; //colour
  1896.                 }
  1897.  
  1898.                 ptr->number=teams[i].shirt;
  1899.  
  1900.                 x=(teams[i].tm_xdis); //x
  1901.                 y=(teams[i].tm_ydis); //y
  1902.  
  1903.                 ptr->crot=x;
  1904.                 ptr->srot=y;
  1905.  
  1906.                 ptr->anim=teams[i].tm_anim;
  1907.                 ptr->frame=teams[i].tm_frm;
  1908.                 ptr->fstep=teams[i].tm_fstep;
  1909.  
  1910.                 ptr->htype=(float)teams[i].tm_htype;
  1911.                 ptr->hcol=(float)teams[i].tm_hcol;
  1912.  
  1913.                 if (speech_tab[i].cnt)
  1914.                     ptr->sprite=speech_tab[i].say;
  1915.                 else
  1916.                     ptr->sprite=-1;
  1917.  
  1918.                 ptr++;
  1919.             }
  1920.         }
  1921.         ptr->x=ballx;
  1922.         ptr->y=ballz;
  1923. //        ptr->y=ball_diam/2+ballz-0.5;
  1924.         ptr->z=bally;
  1925.  
  1926.         ptr->type=0;             //ball type
  1927.  
  1928.         ptr->crot=cos(ball_horz_ang-PI/2);
  1929.         ptr->srot=sin(ball_horz_ang-PI/2);
  1930.  
  1931.         ptr->anim=0;
  1932.         ptr->frame=cos(ball_vert_ang);
  1933.         ptr->fstep=sin(ball_vert_ang);
  1934.  
  1935.         ptr->sprite=0;
  1936.  
  1937.         ptr++;
  1938.  
  1939. // Store in replay array...
  1940.         if (replay_seconds)
  1941.             memcpy(rep,ptr-ncb,sizeof(plyrdat)*ncb);
  1942.  
  1943.     }
  1944. }
  1945.  
  1946. /******************************************************************************
  1947. *****************************************************************************/
  1948.  
  1949. void switch_coords()
  1950. {
  1951.     if (new_coords==coords_tab1)
  1952.     {
  1953.         new_coords=coords_tab2;
  1954.         old_coords=coords_tab1;
  1955.     }
  1956.     else
  1957.     {
  1958.         new_coords=coords_tab1;
  1959.         old_coords=coords_tab2;
  1960.     }
  1961. }
  1962.  
  1963. /******************************************************************************
  1964. *****************************************************************************/
  1965.  
  1966. void new_update_coords()
  1967. {
  1968.     switch_coords();
  1969.     pass_coords(new_coords);
  1970. }
  1971.  
  1972. /******************************************************************************
  1973. *****************************************************************************/
  1974.  
  1975. void realtime_coords()
  1976. {
  1977.     double n;
  1978.     plyrdat *old=old_coords;
  1979.     plyrdat *newp=new_coords;
  1980.     plyrdat *ptr=pos;
  1981.     float ox,oy,nx,ny,dif;
  1982.     int col;
  1983.  
  1984.     if (tweening)
  1985.     {
  1986.         for (int i=0; i<players+3; i++)
  1987.         {
  1988.             if ((teams[i].guy_on) || (i>=players))
  1989.             {
  1990.                 nx=newp->x;
  1991.                 ox=old->x;
  1992.                 nx=ox+((nx-ox)*mf_scale);
  1993.                 ptr->x=nx;
  1994.  
  1995.                 nx=newp->y;
  1996.                 ox=old->y;
  1997.                 nx=ox+((nx-ox)*mf_scale);
  1998.                 ptr->y=nx;
  1999.  
  2000.                 nx=newp->z;
  2001.                 ox=old->z;
  2002.                 nx=ox+((nx-ox)*mf_scale);
  2003.                 ptr->z=nx;
  2004.  
  2005.                 ptr->type=newp->type;        //col
  2006.                 ptr->number=newp->number;    // shirt no.
  2007.  
  2008.                 ox=(old->crot);
  2009.                 oy=(old->srot);
  2010.  
  2011.                 nx=(newp->crot);
  2012.                 ny=(newp->srot);
  2013.  
  2014. // get difference...
  2015.                 dif=((nx*ox)+(ny*oy));
  2016.  
  2017.                 if (dif>1.0)
  2018.                     dif=1;
  2019.  
  2020.                 if (dif<-1.0)
  2021.                     dif=-1;
  2022.  
  2023.                 dif=acos(dif);
  2024.  
  2025.                 dif=dif*mf_scale;
  2026.  
  2027. // Which way to turn?
  2028.                 if ((nx*oy)<(ny*ox))
  2029.                     dif=-dif;
  2030.     
  2031.                 nx=(ox*cos(dif))+(oy*sin(dif));
  2032.                 ny=(oy*cos(dif))-(ox*sin(dif));
  2033.  
  2034.                 ptr->crot=-nx;    //xd
  2035.                 ptr->srot=ny;    //yd
  2036.  
  2037. // Animation seq...
  2038.                 ptr->anim=newp->anim;
  2039.  
  2040. // Animation frame...
  2041.                 if ((i>=players && refs[i-players].newanim)
  2042.                      || (teams[i].tm_newanim && i<players))
  2043.                 {
  2044.                     nx=modf(newp->frame,&n);
  2045.                     ptr->frame=nx;        // Initial frame...
  2046.                     if (i>=players)
  2047.                         refs[i-players].newanim=FALSE;
  2048.                     else
  2049.                         teams[i].tm_newanim=FALSE;
  2050.                     old->frame=0;
  2051.                 }
  2052.                 else
  2053.                 {
  2054.                     nx=newp->frame;
  2055.                     ox=old->frame;
  2056.                     if (nx<ox)
  2057. // Prevent backwards tweening...(looks bad in slow motion!)
  2058.                         nx+=1;
  2059.  
  2060.                     nx=ox+((nx-ox)*mf_scale);
  2061.                     nx=modf(nx,&n);
  2062.                     ptr->frame=nx;
  2063.                     if (i==11)
  2064.                         deb_data=nx;
  2065.                 }
  2066.  
  2067.                 ptr->fstep=newp->fstep;
  2068.  
  2069.                 ptr->htype=newp->htype;
  2070.                 ptr->hcol=newp->hcol;
  2071.  
  2072.                 ptr->sprite=newp->sprite;
  2073.             }
  2074.             else
  2075.             {
  2076.                 ptr->type=0;        //Off!
  2077.             }
  2078.  
  2079.         ptr++;
  2080.         newp++;
  2081.         old++;
  2082.  
  2083.         }
  2084.  
  2085. // Ball...
  2086.  
  2087.         nx=newp->x;
  2088.         ox=old->x;
  2089.         nx=ox+((nx-ox)*mf_scale);
  2090.         ptr->x=nx;
  2091.         eff_ballx=nx;
  2092.  
  2093.         nx=newp->y;
  2094.         ox=old->y;
  2095.         nx=ox+((nx-ox)*mf_scale);
  2096.         ptr->y=nx;
  2097.         eff_ballz=nx;
  2098.  
  2099.         nx=newp->z;
  2100.         ox=old->z;
  2101.         nx=ox+((nx-ox)*mf_scale);
  2102.         ptr->z=nx;
  2103.         eff_bally=nx;
  2104.  
  2105.         ptr->type=0;
  2106.  
  2107.         ox=(old->crot);
  2108.         oy=(old->srot);
  2109.  
  2110.         nx=(newp->crot);
  2111.         ny=(newp->srot);
  2112.  
  2113. // get difference...
  2114.         dif=((nx*ox)+(ny*oy));
  2115.  
  2116.         if (dif>1.0)
  2117.             dif=1;
  2118.  
  2119.         if (dif<-1.0)
  2120.             dif=-1;
  2121.  
  2122.         dif=acos(dif);
  2123.  
  2124.         dif=dif*mf_scale;
  2125.  
  2126. // Which way to turn?
  2127.         if ((nx*oy)<(ny*ox))
  2128.             dif=-dif;
  2129.     
  2130.         nx=(ox*cos(dif))+(oy*sin(dif));
  2131.         ny=(oy*cos(dif))-(ox*sin(dif));
  2132.  
  2133.         ptr->crot=nx;
  2134.         ptr->srot=ny;
  2135.  
  2136.         ptr->anim=0;
  2137.  
  2138.         ox=(old->frame);
  2139.         oy=(old->fstep);
  2140.  
  2141.         nx=(newp->frame);
  2142.         ny=(newp->fstep);
  2143.  
  2144. // get difference...
  2145.         dif=((nx*ox)+(ny*oy));
  2146.  
  2147.         if (dif>1.0)
  2148.             dif=1;
  2149.  
  2150.         if (dif<-1.0)
  2151.             dif=-1;
  2152.  
  2153.         dif=acos(dif);
  2154.  
  2155.         dif=dif*mf_scale;
  2156.  
  2157. // Which way to turn?
  2158.         if ((nx*oy)<(ny*ox))
  2159.             dif=-dif;
  2160.  
  2161.         nx=(ox*cos(dif))+(oy*sin(dif));
  2162.         ny=(oy*cos(dif))-(ox*sin(dif));
  2163.  
  2164.         ptr->frame=nx;
  2165.         ptr->fstep=ny;
  2166.         ptr->sprite=0;
  2167.  
  2168.         ptr++;
  2169.         newp++;
  2170.         old++;
  2171.  
  2172.     }
  2173.     else
  2174.     {
  2175.         for (int i=0; i<players+3; i++)
  2176.         {
  2177.             if ((teams[i].guy_on) || (i>=players))
  2178.             {
  2179.                 ptr->x=newp->x;
  2180.                 ptr->y=newp->y;
  2181.                 ptr->z=newp->z;
  2182.  
  2183.                 ptr->type=newp->type;
  2184.                 ptr->number=newp->number;    // shirt no.
  2185.  
  2186.                 ptr->crot=-(newp->crot);
  2187.                 ptr->srot=newp->srot;
  2188.  
  2189.                 nx=newp->anim;
  2190. //                nx=modf(nx,&n);
  2191.                 ptr->anim=nx;
  2192.  
  2193.                 nx=newp->frame;
  2194.                 nx=modf(nx,&n);
  2195.                 ptr->frame=nx;
  2196.  
  2197.                 ptr->fstep=newp->fstep;
  2198.  
  2199.                 ptr->htype=newp->htype;
  2200.                 ptr->hcol=newp->hcol;
  2201.  
  2202.                 ptr->sprite=newp->sprite;
  2203.  
  2204.             }
  2205.             else
  2206.             {
  2207.                 ptr->type=0;        //Off!
  2208.             }
  2209.  
  2210.         ptr++;
  2211.         newp++;
  2212.  
  2213.         }
  2214.  
  2215. // Ball...
  2216.  
  2217.         ptr->x=newp->x;
  2218.         ptr->y=newp->y;
  2219.         ptr->z=newp->z;
  2220.         ptr->crot=newp->crot;
  2221.         ptr->srot=newp->srot;
  2222.         ptr->frame=newp->frame;
  2223.         ptr->fstep=newp->fstep;
  2224.         ptr->sprite=newp->sprite;
  2225.  
  2226.         ptr++;
  2227.         newp++;
  2228.         old++;
  2229.  
  2230.     }
  2231. }
  2232.  
  2233. /******************************************************************************
  2234. *****************************************************************************/
  2235.  
  2236. void sprite3d(short x,short y,short ref)
  2237. {
  2238.     unsigned char *scr=main_buff.buff_start;
  2239.     scr+=(y*320/2)+x/2;
  2240.     if (y<400 && y>=0 && x<640 && x>=0)
  2241.     {
  2242.         if (!ref)
  2243.             *scr=31;
  2244.         else
  2245.             *scr=2;
  2246.     }
  2247.  
  2248. /*
  2249. // OUT
  2250.     switch(ref)
  2251.     {
  2252.         case(SAY_FOUL):
  2253.             speech_bubble(x,y,"FOUL!",&main_buff);
  2254.             break;
  2255.  
  2256.         case(SAY_PASS):
  2257.             speech_bubble(x,y,"To Me!",&main_buff);
  2258.             break;
  2259.  
  2260.         case(SAY_SHIT):
  2261.             speech_bubble(x,y,"Oh Dear!",&main_buff);
  2262.             break;
  2263.  
  2264.         case(SAY_CROSS):
  2265.             speech_bubble(x,y,"On me head!",&main_buff);
  2266.             break;
  2267.  
  2268.         case(SAY_OFFSIDE):
  2269.             speech_bubble(x,y,"OFFSIDE!",&main_buff);
  2270.             break;
  2271.  
  2272.         case(SAY_ADV):
  2273.             speech_bubble(x,y,"Play on...",&main_buff);
  2274.             break;
  2275.  
  2276.         case(SAY_REF):
  2277.             speech_bubble(x,y,"Ref!",&main_buff);
  2278.             break;
  2279.  
  2280.         case(SAY_PENALTY):
  2281.             speech_bubble(x,y,"PENALTY!",&main_buff);
  2282.             break;
  2283.  
  2284.         case(SAY_TIMEW):
  2285.             speech_bubble(x,y,"Time Wasting!",&main_buff);
  2286.             break;
  2287.  
  2288.         default:
  2289.             overlay_sprite(x,y,ref,&main_buff);
  2290.     }
  2291. */
  2292. }
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.         
  2301.